package com.role{
	import com.collection.ConfigCollection;
	import com.utils.Collide;
	
	/**
	 * 创建者：薛恒杰
	 * 工程名称：Marbles
	 * 创建时间：Jul 31, 2012 1:03:41 PM
	 * 类说明：MoveBase.as,
	 */
	public class MoveBase2 extends CycleBase{
		public var u:Number; //摩擦阻尼系数
		 
		public function MoveBase2(life:int, attack:int, defense:int, quality:Number, damp:Number = 0.02, radius:int = 10){
			super(life, attack, defense, radius);
			u = damp;
//			stop();
		}
		/**
		 * 执行移动操作，一般在fire方法设置参数后启动。
		 * @return 返回true则移动上为结束，否则结束。
		 */
		public function execution():Boolean{
			if(speed > 0){
				x += vx;
				y += vy;
				//每次execution, 都移动speed距离, 能量守恒算出终速度
				speed = Math.sqrt(speed*speed - 2*u*ConfigCollection.g*speed);
				return true;
			} else {
				stop();
				return false;
			}
		}
		/**
		 * 移动前的参数设置。
		 * @param angle 要移动的角度
		 * @param speed 移动注入的速度比例
		 */
		public function fire(angle:Number, speed:Number):void{
			this.speed = speed;
			this.angle = angle;
			trace('发射角度',angle )
		}
		
		public function stop():void{
			speed = 0;
//			angle = 0;
		}
		
		
		//*************get  set**************
		public function get vy():Number{
			return _collide.speedy;//有方向
		}//close get 
		public function get vx():Number{
			return _collide.speedx;//有方向
		}//close get
		public function get speed():Number{
			return _collide.speed;
		}
		public function set speed(value:Number):void{
			_collide.speed = value;
		}//close get set
		public function get angle():Number{
			return _collide.angle;
		}
		public function set angle(value:Number):void{
			_collide.angle = value;
		}//close get set
		public function get quality():Number{
			return _collide.quality;
		}
		public function set quality(value:Number):void{
			if (value < 0)value = ConfigCollection.Mini;//系统极小值
			_collide.quality = value;
		}//close get set
		override public function get collide():Collide{
//			_collide.speed = _speed + aSpeed * time;
			return _collide;
		}//close get
	}
}